package com.boruishangge.persagysdk.entiy;

import android.text.TextUtils;

import java.io.Serializable;

/**
 * Project Name：EquipmentManagement.
 * Created by Administrator on 2015/11/26 17:22.
 */
public class BaseModel<T> implements Serializable {

    private String respCode;
    private String respMsg;
    private int count;



    //服务器1
    private String result;
    private String reason;
    private T content;
    //服务器2
    private String Result;
    private String ResultMsg;
    private T Content;
    private T Item;
    public int Count;


    public String getRespCode() {
        return respCode;
    }

    public void setRespCode(String respCode) {
        this.respCode = respCode;
    }

    public String getRespMsg() {
        return respMsg;
    }

    public void setRespMsg(String respMsg) {
        this.respMsg = respMsg;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public boolean isSuccess() {
        return "success".equals(result) || "success".equals(Result);
    }

    public String getResult() {
        return TextUtils.isEmpty(result) ? Result : result;
    }

    public String getMsg() {
        if (TextUtils.isEmpty(reason) && TextUtils.isEmpty(ResultMsg)) {
            return "请求失败";
        }
        return TextUtils.isEmpty(reason) ? ResultMsg : reason;
    }

    public T getData() {
        return null == content ? (null == Content ? Item : Content) : content;
    }

    /**
     * 注意，后台返回不一致
     * 事件管理-我的模块如果T为null，返回的是空数组，就传递此集合，否则直接传递Nothing类
     * 如果T为null则泛型传此类-比如发布成功类的回调，修改个人信息的回调
     */
    public static class Nothing {

    }

}
